package com.ts.api.module.api.convert.receive.context;

import com.ts.api.common.constant.api.ApiEnum;
import com.ts.api.exp.ApiMsgException;
import com.ts.api.module.api.convert.receive.convert.ApiReceivePhoneMaskConvert;
import com.ts.api.module.api.convert.receive.handler.ApiReceivePhoneMaskConvertHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *  API渠道转换器上下文
 *
 *  @author Pan
 */
@Component
public class ApiReceivePhoneMaskConvertContext {

    @Autowired
    private ApiReceivePhoneMaskConvert apiReceivePhoneMaskConvert;

    /**
     *  获取-上游解析上下文
     *
     *  @author Pan
     *  @param  apiClientId  客户端id
     *  @return ApiReceivePhoneMaskConvertHandler
     */
    public ApiReceivePhoneMaskConvertHandler getReceive(String apiClientId) {
        ApiReceivePhoneMaskConvertHandler handler = apiReceivePhoneMaskConvert.getHandler(apiClientId);
        if (handler == null) {
            throw new ApiMsgException(ApiEnum.API_NULL_FAIL.format("API渠道-掩码模式-无对应解析器", "null"));
        }
        return handler;
    }
}
